package com.aida.evil.eda.Toast;

import android.app.Activity;
import android.os.Parcelable;
import android.view.View;

import com.github.johnpersano.supertoasts.SuperActivityToast;
import com.github.johnpersano.supertoasts.SuperToast;
import com.github.johnpersano.supertoasts.util.OnClickWrapper;

/********************************************
 * 工程名：Aida
 * 包名：com.aida.evil.eda.Toast
 * 时间：16-5-11 下午6:03
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class CustomSuperActivityToast
{
    private Activity activity;
    private static SuperActivityToast superActivityToast;
    private static CustomSuperActivityToast customSuperActivityToast;

    public CustomSuperActivityToast(Activity activity)
    {
        this.activity = activity;
        superActivityToast = new SuperActivityToast(activity, SuperToast.Type.BUTTON);
    }

    public CustomSuperActivityToast(Activity activity, SuperToast.Type type)
    {
        this.activity = activity;
        superActivityToast = new SuperActivityToast(activity, type);
    }

    public static CustomSuperActivityToast makeText(Activity activity)
    {
        customSuperActivityToast = new CustomSuperActivityToast(activity);

        return customSuperActivityToast;
    }

    public static CustomSuperActivityToast makeText(Activity activity, String context, String buttonContext)
    {
        customSuperActivityToast = new CustomSuperActivityToast(activity);

        superActivityToast.setText(context);
        superActivityToast.setButtonText(buttonContext);
        superActivityToast.setBackground(SuperToast.Background.BLUE);
        superActivityToast.setTouchToDismiss(true);
        superActivityToast.setAnimations(SuperToast.Animations.FLYIN);

        return customSuperActivityToast;
    }

    public static CustomSuperActivityToast makeText(Activity activity, String context, String buttonContext, SuperToast.OnClickListener buttonOnclik)
    {
        customSuperActivityToast = new CustomSuperActivityToast(activity);

        superActivityToast.setText(context);
        superActivityToast.setButtonText(buttonContext);
        superActivityToast.setOnClickWrapper(new OnClickWrapper("" + activity, buttonOnclik));
        superActivityToast.setBackground(SuperToast.Background.BLUE);
        superActivityToast.setTouchToDismiss(true);
        superActivityToast.setAnimations(SuperToast.Animations.FLYIN);

        return customSuperActivityToast;
    }


    public static CustomSuperActivityToast makeText(Activity activity, SuperToast.Type type)
    {
        customSuperActivityToast = new CustomSuperActivityToast(activity, type);

        return customSuperActivityToast;
    }

    /**
     * 设置提示文字内容
     *
     * @param context
     * @return
     */
    public CustomSuperActivityToast setText(String context)
    {
        superActivityToast.setText(context);
        return customSuperActivityToast;
    }

    /**
     * 设置按钮文字
     *
     * @param buttonContext
     * @return
     */
    public CustomSuperActivityToast setButtonText(String buttonContext)
    {
        superActivityToast.setButtonText(buttonContext);
        return customSuperActivityToast;
    }

    /**
     * 设置button图片
     *
     * @param buttonIcon
     * @return
     */
    public CustomSuperActivityToast setButtonIcon(int buttonIcon)
    {
        superActivityToast.setButtonIcon(buttonIcon);
        return customSuperActivityToast;
    }


    /**
     * 按钮点击事件
     *
     * @param buttonOnclik
     * @return
     */
    public CustomSuperActivityToast setButtonOnclik(SuperToast.OnClickListener buttonOnclik)
    {
        superActivityToast.setOnClickWrapper(new OnClickWrapper("" + activity, buttonOnclik));
        return customSuperActivityToast;
    }

    /**
     * 设置间隔时间
     *
     * @param duration
     * @return
     */
    public CustomSuperActivityToast setDuration(int duration)
    {
        superActivityToast.setDuration(duration);
        return customSuperActivityToast;
    }

    /**
     * 设置背景颜色
     *
     * @param background
     * @return
     */
    public CustomSuperActivityToast setBackground(int background)
    {
        superActivityToast.setBackground(background);
        return customSuperActivityToast;
    }

    /**
     * 设置是否触摸消失
     *
     * @param b true 触摸消失 false 触摸不消失
     * @return
     */
    public CustomSuperActivityToast setTouchToDismiss(boolean b)
    {
        superActivityToast.setTouchToDismiss(b);
        return customSuperActivityToast;
    }

    /**
     * 设置弹出动画
     *
     * @param animations
     * @return
     */
    public CustomSuperActivityToast setAnimations(SuperToast.Animations animations)
    {
        superActivityToast.setAnimations(animations);
        return customSuperActivityToast;
    }

    /**
     * 显示
     */
    public CustomSuperActivityToast show()
    {
        superActivityToast.show();
        return customSuperActivityToast;
    }
}
